﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Assets.Core.Common.Web
{
    public class Result<T>
    {
        /// <summary>
        /// 执行的结果
        /// </summary>
        public bool Success { get; set; }

        public int Code { get; set; } = 200;
        /// <summary>
        /// 错误消息
        /// </summary>
        public string Msg { get; set; } = "ok";

        /// <summary>
        /// 执行返回的数据
        /// </summary>
        public T Data { get; set; }

        public static Result<T> success(T data)
        {
            return new Result<T> { Success = true, Code = 200, Data = data , Msg = "操作成功" };
        }
        public static Result<T> fail(string msg)
        {
            return new Result<T> { Success = false, Code = 300, Msg = msg };
        }
        public  static Result<T> error(string msg)
        {
            return new Result<T> { Success = false, Code = 500 , Msg = msg };
        }
    }
    public class Result: Result<object>
    {
        public static new Result success()
        {
            return new Result { Success = true, Code = 200,  Msg = "操作成功" };
        }
        public static new Result success(object data)
        {
            return new Result { Success = true, Code = 200, Data = data,Msg="操作成功" };
        }
     
        
        public static new Result fail(string msg)
        {
            return new Result { Success = false, Code = 300 ,Msg=msg};
        }
       
        public static new Result error(string msg)
        {
            return new Result { Success = false, Code = 500 ,Msg=msg};
        }
        
    }
}
